package com.turing.post.datatranfer.impl;

import java.util.List;

import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import com.turing.post.datatranfer.util.CardControl;
import com.turing.post.datatranfer.util.CardControlDao;
/**
 * 卡控制接口实现
 * @author WZD
 *
 */
@Stateless(mappedName = "datatranfer.impl.CardControlDaoImpl")
@Remote
@Local
public class CardControlDaoImpl implements CardControlDao {
	/**
	 * 实体管理器
	 */
	@PersistenceContext
	protected EntityManager _em;
	
	@SuppressWarnings("unchecked")
	@Override
	public List<Object[]> getCardControlList() {
		String sql = "select BATCHNO,BRANCHNO,OPERNO,to_char(MAKESTARTTIME,'yyyy-mm-dd hh:mi:ss'),to_char(MAKEENDTIME,'yyyy-mm-dd hh:mi:ss'),CARDKINDID,CARDPARVALUE,CARDCOUNT,EXPIRED,STATUS,AUTHOPERNO from CardControl where Status='3' order by makeStartTime desc ";
		Query query = _em.createNativeQuery(sql);
		List<Object[]> obj_list = query.getResultList();
		return obj_list;
	}

	@Override
	public CardControl getCardControlByBatchNo(String batchNo) {
		return _em.find(CardControl.class, batchNo);
	}

}
